<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="tea2Name">
        <el-input
          v-model="queryParams.tea2Name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="性别" prop="tea2Gender">
        <el-select v-model="queryParams.tea2Gender" placeholder="请选择性别" clearable>
          <el-option
            v-for="dict in dict.type.sys_user_sex"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="任教类型" prop="tea2TeachingType">
        <el-select v-model="queryParams.tea2TeachingType" placeholder="请选择任教类型" clearable>
          <el-option
            v-for="dict in dict.type.tea_teach_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="任教专业名称" prop="tea2MajorName">
        <el-input
          v-model="queryParams.tea2MajorName"
          placeholder="请输入任教专业名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="任教专业代码" prop="tea2MajorCode">
        <el-input
          v-model="queryParams.tea2MajorCode"
          placeholder="请输入任教专业代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="专业任教时间" prop="tea2TeachingYear">
        <el-date-picker clearable
          v-model="queryParams.tea2TeachingYear"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择专业任教时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否实验技术人员" prop="tea2ExperimentalTechnician">
        <el-select v-model="queryParams.tea2ExperimentalTechnician" placeholder="请选择是否实验技术人员" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否双师双能型" prop="tea2DualQualified">
        <el-select v-model="queryParams.tea2DualQualified" placeholder="请选择是否双师双能型" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否工程背景" prop="tea2EngineeringBackground">
        <el-select v-model="queryParams.tea2EngineeringBackground" placeholder="请选择是否工程背景" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否行业背景" prop="tea2IndustryBackground">
        <el-select v-model="queryParams.tea2IndustryBackground" placeholder="请选择是否行业背景" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否有国" prop="tea2ForeignExperience">
        <el-select v-model="queryParams.tea2ForeignExperience" placeholder="请选择是否有国" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="管理人员类别" prop="tea2Ctrl">
        <el-select v-model="queryParams.tea2Ctrl" placeholder="请选择管理人员类别" clearable>
          <el-option
            v-for="dict in dict.type.teac_manager_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="职称" prop="tea2Title">
        <el-select v-model="queryParams.tea2Title" placeholder="请选择职称" clearable>
          <el-option
            v-for="dict in dict.type.jw_teacher_title"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="职称名称" prop="tea2TitleName">
        <el-input
          v-model="queryParams.tea2TitleName"
          placeholder="请输入职称名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评职时间">
        <el-date-picker
          v-model="daterangeTea2GetTime"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="身份证号" prop="tea2IdNum">
        <el-input
          v-model="queryParams.tea2IdNum"
          placeholder="请输入身份证号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生日期">
        <el-date-picker
          v-model="daterangeTea2Birthday"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="审核状态" prop="auditStatus">
        <el-select v-model="queryParams.auditStatus" placeholder="请选择审核状态" clearable>
          <el-option
            v-for="dict in dict.type.audit_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['teachers:teachers:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['teachers:teachers:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['teachers:teachers:remove']"
        >删除</el-button>
      </el-col>
      <!-- 审核   -->
      <el-col :span="1.5">
        <el-button
          type="info"
          icon="el-icon-check"
          size="mini"
          @click="openAuditDialog"
          :disabled="multiple"
          v-hasPermi="['system:check']"
          plain
        >审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['teachers:teachers:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 确保visible是通过sync双向绑定 -->
    <audit-dialog
      :visible.sync="auditDialogVisible"
      table_name="jw_teachers"
      id_name="id"
      ref="audit"
      @submit="handleAuditSubmit"
    />

    <el-table v-loading="loading" :data="teachersList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="工号" align="center" prop="tea2Code" />
      <el-table-column label="姓名" align="center" prop="tea2Name" />
      <el-table-column label="性别" align="center" prop="tea2Gender">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.tea2Gender"/>
        </template>
      </el-table-column>
      <el-table-column label="任教类型" align="center" prop="tea2TeachingType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.tea_teach_type" :value="scope.row.tea2TeachingType"/>
        </template>
      </el-table-column>
      <el-table-column label="任教专业名称" align="center" prop="tea2MajorName" />
      <el-table-column label="任教专业代码" align="center" prop="tea2MajorCode" />
      <el-table-column label="专业任教时间" align="center" prop="tea2TeachingYear" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tea2TeachingYear, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否实验技术人员" align="center" prop="tea2ExperimentalTechnician">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.tea2ExperimentalTechnician"/>
        </template>
      </el-table-column>
      <el-table-column label="是否双师双能型" align="center" prop="tea2DualQualified">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.tea2DualQualified"/>
        </template>
      </el-table-column>
      <el-table-column label="是否工程背景" align="center" prop="tea2EngineeringBackground">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.tea2EngineeringBackground"/>
        </template>
      </el-table-column>
      <el-table-column label="是否行业背景" align="center" prop="tea2IndustryBackground">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.tea2IndustryBackground"/>
        </template>
      </el-table-column>
      <el-table-column label="是否有国" align="center" prop="tea2ForeignExperience">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.tea2ForeignExperience"/>
        </template>
      </el-table-column>
      <el-table-column label="管理人员类别" align="center" prop="tea2Ctrl">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.teac_manager_type" :value="scope.row.tea2Ctrl"/>
        </template>
      </el-table-column>
      <el-table-column label="职称" align="center" prop="tea2Title">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.jw_teacher_title" :value="scope.row.tea2Title"/>
        </template>
      </el-table-column>
      <el-table-column label="职称名称" align="center" prop="tea2TitleName" />
      <el-table-column label="评职时间" align="center" prop="tea2GetTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tea2GetTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="身份证号" align="center" prop="tea2IdNum" />
      <el-table-column label="出生日期" align="center" prop="tea2Birthday" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tea2Birthday, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="联系电话" align="center" prop="tea2Tel" />
      <el-table-column label="邮箱" align="center" prop="tea2Email" />
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核状态" align="center" prop="auditStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.audit_status" :value="scope.row.auditStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="未通过原因" align="center" prop="rejectionReason" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['teachers:teachers:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['teachers:teachers:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改教师管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1040px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px" :inline="true">
        <el-form-item label="工号" prop="tea2Code">
          <el-input v-model="form.tea2Code" placeholder="请输入工号" />
        </el-form-item>
        <el-form-item label="姓名" prop="tea2Name">
          <el-input v-model="form.tea2Name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="性别" prop="tea2Gender">
          <el-select v-model="form.tea2Gender" placeholder="请选择性别">
            <el-option
              v-for="dict in dict.type.sys_user_sex"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任教类型" prop="tea2TeachingType">
          <el-select v-model="form.tea2TeachingType" placeholder="请选择任教类型">
            <el-option
              v-for="dict in dict.type.tea_teach_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任教专业名称" prop="tea2MajorName">
          <el-input v-model="form.tea2MajorName" placeholder="请输入任教专业名称" />
        </el-form-item>
        <el-form-item label="任教专业代码" prop="tea2MajorCode">
          <el-input v-model="form.tea2MajorCode" placeholder="请输入任教专业代码" />
        </el-form-item>
        <el-form-item label="专业任教时间" prop="tea2TeachingYear">
          <el-date-picker clearable
            v-model="form.tea2TeachingYear"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择专业任教时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否实验技术人员" prop="tea2ExperimentalTechnician">
          <el-select v-model="form.tea2ExperimentalTechnician" placeholder="请选择是否实验技术人员">
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否双师双能型" prop="tea2DualQualified">
          <el-select v-model="form.tea2DualQualified" placeholder="请选择是否双师双能型">
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否工程背景" prop="tea2EngineeringBackground">
          <el-select v-model="form.tea2EngineeringBackground" placeholder="请选择是否工程背景">
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否行业背景" prop="tea2IndustryBackground">
          <el-select v-model="form.tea2IndustryBackground" placeholder="请选择是否行业背景">
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否有国" prop="tea2ForeignExperience">
          <el-select v-model="form.tea2ForeignExperience" placeholder="请选择是否有国">
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="管理人员类别" prop="tea2Ctrl">
          <el-select v-model="form.tea2Ctrl" placeholder="请选择管理人员类别">
            <el-option
              v-for="dict in dict.type.teac_manager_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="职称" prop="tea2Title">
          <el-select v-model="form.tea2Title" placeholder="请选择职称">
            <el-option
              v-for="dict in dict.type.jw_teacher_title"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="职称名称" prop="tea2TitleName">
          <el-input v-model="form.tea2TitleName" placeholder="请输入职称名称" />
        </el-form-item>
        <el-form-item label="评职时间" prop="tea2GetTime">
          <el-date-picker clearable
            v-model="form.tea2GetTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择评职时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="身份证号" prop="tea2IdNum">
          <el-input v-model="form.tea2IdNum" placeholder="请输入身份证号" />
        </el-form-item>
        <el-form-item label="出生日期" prop="tea2Birthday">
          <el-date-picker clearable
            v-model="form.tea2Birthday"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择出生日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="联系电话" prop="tea2Tel">
          <el-input v-model="form.tea2Tel" placeholder="请输入联系电话" />
        </el-form-item>
        <el-form-item label="邮箱" prop="tea2Email">
          <el-input v-model="form.tea2Email" placeholder="请输入邮箱" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listTeachers, getTeachers, delTeachers, addTeachers, updateTeachers } from "@/api/teachers/teachers";
import AuditDialog from '@/components/AuditDialog/AuditDialog.vue'; // 引入审核子组件

export default {
  name: "Teachers",
  dicts: ['jw_teacher_title', 'teac_manager_type', 'sys_yes_no', 'tea_teach_type', 'audit_status', 'sys_user_sex'],
  components: { AuditDialog },
  data() {
    return {
      // 控制审核对话框的显示
      auditDialogVisible: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 教师管理表格数据
      teachersList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 邮箱时间范围
      daterangeTea2GetTime: [],
      // 邮箱时间范围
      daterangeTea2Birthday: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        tea2Name: null,
        tea2Gender: null,
        tea2TeachingType: null,
        tea2MajorName: null,
        tea2MajorCode: null,
        tea2TeachingYear: null,
        tea2ExperimentalTechnician: null,
        tea2DualQualified: null,
        tea2EngineeringBackground: null,
        tea2IndustryBackground: null,
        tea2ForeignExperience: null,
        tea2Ctrl: null,
        tea2Title: null,
        tea2TitleName: null,
        tea2GetTime: null,
        tea2IdNum: null,
        tea2Birthday: null,
        auditStatus: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        tea2Code: [
          { required: true, message: "工号不能为空", trigger: "blur" }
        ],
        tea2Name: [
          { required: true, message: "姓名不能为空", trigger: "blur" }
        ],
        tea2TeachingType: [
          { required: true, message: "任教类型不能为空", trigger: "change" }
        ],
        tea2TeachingYear: [
          { required: true, message: "专业任教时间不能为空", trigger: "blur" }
        ],
        tea2ExperimentalTechnician: [
          { required: true, message: "是否实验技术人员不能为空", trigger: "change" }
        ],
        tea2DualQualified: [
          { required: true, message: "是否双师双能型不能为空", trigger: "change" }
        ],
        tea2EngineeringBackground: [
          { required: true, message: "是否工程背景不能为空", trigger: "change" }
        ],
        tea2IndustryBackground: [
          { required: true, message: "是否行业背景不能为空", trigger: "change" }
        ],
        tea2ForeignExperience: [
          { required: true, message: "是否有国不能为空", trigger: "change" }
        ],
        tea2Ctrl: [
          { required: true, message: "管理人员类别不能为空", trigger: "change" }
        ],
        tea2Title: [
          { required: true, message: "职称不能为空", trigger: "change" }
        ],
        tea2IdNum: [
          { required: true, message: "身份证号不能为空", trigger: "blur" }
        ],
        tea2Birthday: [
          { required: true, message: "出生日期不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 打开审核对话框
    openAuditDialog() {
      if(this.ids!=null)
      {
        this.auditDialogVisible = true; // 显示审核对话框
        this.$refs['audit'].setData(this.ids);
      }
      else
        this.$message.error("请选择要审核的信息");
    },
    // 提交审核数据
    async handleAuditSubmit() {
      this.auditDialogVisible = false; // 关闭审核对话框
      await this.getList(); // 刷新数据列表
    },
    /** 查询教师管理列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeTea2GetTime && '' != this.daterangeTea2GetTime) {
        this.queryParams.params["beginTea2GetTime"] = this.daterangeTea2GetTime[0];
        this.queryParams.params["endTea2GetTime"] = this.daterangeTea2GetTime[1];
      }
      if (null != this.daterangeTea2Birthday && '' != this.daterangeTea2Birthday) {
        this.queryParams.params["beginTea2Birthday"] = this.daterangeTea2Birthday[0];
        this.queryParams.params["endTea2Birthday"] = this.daterangeTea2Birthday[1];
      }
      listTeachers(this.queryParams).then(response => {
        this.teachersList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        tea2Code: null,
        tea2Name: null,
        tea2Gender: null,
        tea2TeachingType: null,
        tea2MajorName: null,
        tea2MajorCode: null,
        tea2TeachingYear: null,
        tea2ExperimentalTechnician: null,
        tea2DualQualified: null,
        tea2EngineeringBackground: null,
        tea2IndustryBackground: null,
        tea2ForeignExperience: null,
        tea2Ctrl: null,
        tea2Title: null,
        tea2TitleName: null,
        tea2GetTime: null,
        tea2IdNum: null,
        tea2Birthday: null,
        tea2Tel: null,
        tea2Email: null,
        userId: null,
        deptId: null,
        updateTime: null,
        auditStatus: null,
        rejectionReason: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeTea2GetTime = [];
      this.daterangeTea2Birthday = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加教师管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTeachers(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改教师管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTeachers(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTeachers(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除教师管理编号为"' + ids + '"的数据项？').then(function() {
        return delTeachers(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('teachers/teachers/export', {
        ...this.queryParams
      }, `teachers_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
